package com.example.androidtest.demo1

import android.util.Log
import java.util.concurrent.Executor
import java.util.concurrent.Executors

class TestMain {

}
fun main() {

    var ticket: Ticket = Ticket()
    var executor: Executor = Executors.newFixedThreadPool(5)
//    executor.execute {
//        while (true){
//            ticket.addTicket("线程aaa")
//            Thread.sleep(2000)
//        }
//    }
//    executor.execute {
//        while (true){
//            ticket.addTicket("线程bbb")
//            Thread.sleep(2000)
//        }
//    }
    executor.execute {
        while (true) {
            try {
                ticket.sealTicket("线程1")
                Thread.sleep(1000)
            } catch (e: InterruptedException) {
                e.printStackTrace()
            }
        }
    }

    executor.execute {
        while (true) {
            try {
                ticket.sealTicket("线程2")
                Thread.sleep(1000)
            } catch (e: InterruptedException) {
                e.printStackTrace()
            }
        }
    }

}
